package com.meaningless;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
public class YearMonth {
    private final int year;
    private final int month;

    private YearMonth(int year, int month) {
        if (year < 0) throw new IllegalArgumentException("Year must be positive");
        if (month < 1 || month > 12) throw new IllegalArgumentException("Month must be 1-12");
        this.year = year;
        this.month = month;
    }

    public YearMonth next() {
        if (month == 12) {
            return YearMonth.of(year + 1, 1);
        }
        return YearMonth.of(year, month + 1);
    }

    public static YearMonth of(int year, int month) {
        return new YearMonth(year, month);
    }
}